#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <math.h>
#include<algorithm>
using namespace std;

int main() {
    int cost[10010] = { 0 };
    int n;
    cin >> n;
    int minc[10010] = { 0 };
    for (int i = 0; i < n; i++)
    {
        cin >> cost[i];
        if (i >= 2) minc[i] = cost[i] + min(minc[i - 1], minc[i - 2]);
        else minc[i] = cost[i];
    }
    int ret = min(minc[n - 1], minc[n - 2]);
    cout << ret;
    return 0;
}
